package cc.md888.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class PageQuery<T> {

    @ApiModelProperty(value = "页码", example = "1")
    @Min(value = 1, message = "分页参数不正确")
    private int pageIndex;

    @ApiModelProperty(value = "分页大小", example = "20")
    @Min(value = 1, message = "分页参数不正确")
    @Max(value = 500, message = "分页大小不能超过500")
    private int pageSize;

    @ApiModelProperty("查询数据")
    private T data;

    @JsonIgnore
    public boolean isFirstPage() {
        return pageIndex == 1;
    }
}
